package com.example.httplibrary.https

import com.example.httplibrary.beans.AuthResponse
import com.example.httplibrary.beans.QrCodeResultBean
import com.example.httplibrary.beans.UploadResponse
import com.example.httplibrary.beans.User
import com.example.httplibrary.beans.VisitorDataListRequestBean
import com.example.httplibrary.beans.VisitorDataListResultBean
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Response
import retrofit2.http.*

/**
 * @author 郑
 * @date 2025/8/4.
 * qq：331758871
 * phone：18979397268
 */
// ApiService.kt
interface ApiService {

    // GET 请求示例
    @GET("users/{userId}")
    suspend fun getUser(@Path("userId") userId: String): Response<User>

    // POST 请求示例（表单提交）
    @FormUrlEncoded
    @POST("auth/login")
    suspend fun login(
        @Field("username") username: String,
        @Field("password") password: String
    ): Response<AuthResponse>

    // POST 请求示例（JSON Body）
    @POST("users/create")
    suspend fun createUser(@Body user: User): Response<User>

    // 文件上传
    @Multipart
    @POST("files/upload")
    suspend fun uploadFile(
        @Part file: MultipartBody.Part,
        @Part("description") description: RequestBody
    ): Response<UploadResponse>

    // 文件下载
    @Streaming
    @GET
    suspend fun downloadFile(@Url fileUrl: String): Response<ResponseBody>

    // 6、访客查询
    @GET("./visitorMachine/visitorDataList")
    suspend fun visitorDataList( @Query("pageNo") pageNo: Int,
                                 @Query("pageSize") pageSize: Int,
                                 @Query("time") time: String,
                                 @Query("code") code: String): Response<VisitorDataListResultBean>


    //首页二维码展示
    @GET("./visitorMachine/getTemporaryVisitorQrCode")
    suspend fun getTemporaryVisitorQrCode(): Response<QrCodeResultBean>


}